#pragma once
#include <ctime>

#define INF 0
#define DBG 1
#define ERR 2
#define LOG_LEVEL INF

#define LOG(level,format,...) do\
{\
    if(level<LOG_LEVEL) break;\
    time_t t = time(nullptr);\
    struct tm * ltm = localtime(&t);\
    char tmp[64] = {0};\
    strftime(tmp,63,"%Y-%m-%d %H:%M:%S",ltm);\
    fprintf(stdout,"[%ld %s %s:%d] " format "\n",pthread_self(),tmp,__FILE__,__LINE__,##__VA_ARGS__);\
} while(0)

#define ILOG(format,...) LOG(INF,format,##__VA_ARGS__)
#define DLOG(format,...) LOG(DBG,format,##__VA_ARGS__)
#define ELOG(format,...) LOG(ERR,format,##__VA_ARGS__)

